home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 2
/
Aminet AMIGA CDROM (1994)(Walnut Creek)[Feb 1994][W.O. 44790-1].iso
/
Aminet
/
dev
/
amos
/
ldosv25d.lha
/
ldos_demo
/
examples
/
ldos
/
LineInput.AMOS
/
LineInput.amosSourceCode
Wrap
AMOS Source Code
|
1992-07-11
|
3KB
|
106 lines
Set Buffer 10
'
' Dedicated to Andy Whitely who thoought Lload and Lstr was a bit
' rough to use, and Line Input much to slow. Using these two procedures
' You can 'emulate' AMOS's Line Input-command. To use it you must
' have LINESTART, LINESTOP (buffer "cursors"), SIZE (load-buffer given
' in Kb), FEOF (internal procedure variable), CHAN (the channel you
' wish to use) and RAD$ (where the read line is placed) GLOBAL!
'
' To use these procedures, simply:
' a) Set CHAN to a number between one and three
' b) Set SIZE to desired size. 4-8 Kb is enoough in most cases
' c0)Set Lset Eoln To desired value (normally 10)
' c) Call _LINEOPEN with the filename
' d) Check Param for errors
' e) Call _LINEINPUT in a loop, until Param is false.
'
' RAD$ will hold your read line. The procedure automatically calls
' Free every time the buffer is re-filled (ie. another block is
' loaded) to prevent AMOS from crashing due to garbage collection.
'
' Please note that these procedures erase and use buffer 8 (you might
' want to change that) and can't handle multiple files (unless you
' re-write the routines :)
'
' Have fun with AMOS!
'
Global LINESTART,LINESTOP
Global CHAN,RAD$,FEOF,SIZE
'
'
Screen Open 1,640,256,2,Hires : Paper 0 : Clw
'
CHAN=3 : Rem These you need to init
SIZE=4
Extension_10_022A 10
'
'---- Open a file for _Lineinput. CHAN is set to 3, buffer 4Kb.
_LINEOPEN["df0:docs/LdosV21.doc"]
If Not Param
Print "Error opening file!"
End
End If
Do
_LINEINPUT
Exit If Not Param
' Print RAD$ : Rem Wait Key
Loop
Extension_10_0016 CHAN
'
'
Procedure _LINEINPUT
If LINESTART>=LINESTOP
If Not FEOF
Gosub _LOAD
Else
SUC=False
Goto SLUT2
End If
End If
'
RAD$= Extension_10_006C(LINESTART To LINESTOP)
LINESTART=LINESTART+Len(RAD$)+1
If(LINESTART>=LINESTOP) and Not(FEOF) and(Peek(LINESTOP)<>10)
Gosub _LOAD
D$= Extension_10_006C(LINESTART To LINESTOP)
LINESTART=LINESTART+Len(D$)+1 : RAD$=RAD$+D$
End If
SUC=True
Goto SLUT2
'
_LOAD:
DUMMY=Free
LINESTART=Start(8)
A= Extension_10_0024(CHAN,LINESTART,SIZE*1024)
If A<SIZE*1024
LINESTOP=LINESTART+A
FEOF=True
End If
Return
SLUT2:
End Proc[SUC]
Procedure _LINEOPEN[F$]
FEOF=False
Erase 8 : Reserve As Work 8,SIZE*1024 : Rem 4 Kb buffer
LINESTART=Start(8)
LINESTOP=LINESTART+SIZE*1024
If Not Exist(F$)
Goto SLUT
Else
If Extension_10_018E(F$)>0 : Rem Dir
Goto SLUT
End If
End If
SUC=True
If Extension_10_0182(F$)<1
SUC=False
End If
Extension_10_0006 CHAN,F$,0
A= Extension_10_0024(CHAN,LINESTART,SIZE*1024)
If A<SIZE*1024
LINESTOP=LINESTART+A
FEOF=True
End If
SLUT:
End Proc[SUC]